program test_tbrconv

    use iasing_osse
    use netcdf
    
    implicit none

    integer :: ionc, ncid
    character(len=64) :: ncfile = &
        "/cnrm/obs/data2/andreyj/4ABis_runs/4ABis_databank_20140930.nc"

    type(r4a_ids) :: db_ids
    type(r4a_dat) :: db_dat

    real(JPR4), dimension(NLMRT) :: yo
    integer :: i

    real(JPR4) :: wnu(NIANG), no_ia(NIASI), no_ng(NIANG)
    real(JPR4), dimension(2116) :: wnu_red, no_nga, no_ngb
    !real(JPR4), dimension(NIANG) :: no_ng


    include "tbrillans_f.interface"
    include "r4a_initializer.interface"
    include "r4a_reader.interface"
    include "interpolProf_f.interface"


    !open(1,file="data/IASInoise_L1C.asc")
    !do i = 1, NIASI
    !    read(1,*) wnu(i), no_ia(i)
    !enddo
    !close (1)

    !print '(TL4,10(F8.5,","), " &")', no_ia

    open(1,file="data/System_NedT_L1C_IASING.txt")
    read(1,*)
    do i = 1, 2116
        read(1,*) wnu_red(i), no_nga(i), no_ngb(i)
    enddo

    wnu = (/(645+(i-1)*RESNG,i=1,NIANG)/)

    no_ng = interpolProf_f(2116, wnu_red, no_nga, NIANG, wnu)
    write(11, '(10(F8.6,","), " &")') no_ng

    no_ng = interpolProf_f(2116, wnu_red, no_ngb, NIANG, wnu)
    write(12, '(10(F8.6,","), " &")') no_ng

    !do i = 1, NIANG
    !    write(13,'(F8.3, F10.6)') wnu(i), no_ng(i)
    !enddo


end program test_tbrconv
